﻿<%@ Page Title="Products" Language="C#" MasterPageFile="~/Master Page/MainMaster.Master" AutoEventWireup="true" CodeBehind="Products.aspx.cs" Inherits="Vortex.Products" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cpHeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="server">
    <asp:LoginView ID="LoginView1" runat="server">
        <AnonymousTemplate>
            You must be logged in to view this.
        </AnonymousTemplate>
        <LoggedInTemplate>
            You're account has not been accesed yet.
            <br />
            Please contact an Administrator for more information.
        </LoggedInTemplate>
        <RoleGroups>
            <asp:RoleGroup Roles="Admin,Manager">
                <ContentTemplate>
                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                        DataKeyNames="pID" DataSourceID="SqlDataSource1" BackColor="White" 
                        BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
                        GridLines="Vertical">
                        <AlternatingRowStyle BackColor="#DCDCDC" />
                        <Columns>
                            <asp:CommandField ShowEditButton="True" />
                            <asp:BoundField DataField="pID" HeaderText="ProductID" ReadOnly="True" 
                                SortExpression="pID" />
                            <asp:BoundField DataField="Product" HeaderText="Product" 
                                SortExpression="Product" />
                            <asp:BoundField DataField="Inventory" HeaderText="Inventory" 
                                SortExpression="Inventory" />
                        </Columns>
                        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                        <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                        <SortedAscendingCellStyle BackColor="#F1F1F1" />
                        <SortedAscendingHeaderStyle BackColor="#0000A9" />
                        <SortedDescendingCellStyle BackColor="#CAC9C9" />
                        <SortedDescendingHeaderStyle BackColor="#000065" />
                    </asp:GridView>
                    <asp:DetailsView ID="DetailsView2" runat="server" AutoGenerateRows="False" 
                        DataKeyNames="pID" DataSourceID="SqlDataSource1" Height="50px" 
                        Width="125px" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" 
                        BorderWidth="1px" CellPadding="3">
                        <EditRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                        <Fields>
                            <asp:BoundField DataField="pID" HeaderText="pID" ReadOnly="True" 
                                SortExpression="pID" />
                            <asp:BoundField DataField="Product" HeaderText="Product" 
                                SortExpression="Product" />
                            <asp:BoundField DataField="Inventory" HeaderText="Inventory" 
                                SortExpression="Inventory" />
                            <asp:CommandField ShowInsertButton="True" />
                        </Fields>
                        <FooterStyle BackColor="White" ForeColor="#000066" />
                        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                        <RowStyle ForeColor="#000066" />
                    </asp:DetailsView>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
                        DeleteCommand="DELETE FROM [Products] WHERE [pID] = @pID" 
                        InsertCommand="INSERT INTO [Products] ([pID], [Product], [Inventory]) VALUES (@pID, @Product, @Inventory)" 
                        SelectCommand="SELECT * FROM [Products] ORDER BY [pID]" 
                        UpdateCommand="UPDATE [Products] SET [Product] = @Product, [Inventory] = @Inventory WHERE [pID] = @pID">
                        <DeleteParameters>
                            <asp:Parameter Name="pID" Type="String" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="pID" Type="String" />
                            <asp:Parameter Name="Product" Type="String" />
                            <asp:Parameter Name="Inventory" Type="Int32" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="Product" Type="String" />
                            <asp:Parameter Name="Inventory" Type="Int32" />
                            <asp:Parameter Name="pID" Type="String" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                </ContentTemplate>
            </asp:RoleGroup>
            <asp:RoleGroup Roles="MarketingTeam">
                <ContentTemplate>
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        DataSourceID="EntityDataSource1" BackColor="White" BorderColor="#999999" 
                        BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
                        <AlternatingRowStyle BackColor="#DCDCDC" />
                        <Columns>
                            <asp:BoundField DataField="pID" HeaderText="ProductID" ReadOnly="True" 
                                SortExpression="pID" />
                            <asp:BoundField DataField="Product1" HeaderText="Product" ReadOnly="True" 
                                SortExpression="Product1" />
                            <asp:BoundField DataField="Inventory" HeaderText="Inventory" ReadOnly="True" 
                                SortExpression="Inventory" />
                        </Columns>
                        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                        <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                        <SortedAscendingCellStyle BackColor="#F1F1F1" />
                        <SortedAscendingHeaderStyle BackColor="#0000A9" />
                        <SortedDescendingCellStyle BackColor="#CAC9C9" />
                        <SortedDescendingHeaderStyle BackColor="#000065" />
                    </asp:GridView>
                    <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
                        ConnectionString="name=VortexEntities" DefaultContainerName="VortexEntities" 
                        EnableFlattening="False" EntitySetName="Products" 
                        Select="it.[pID], it.[Product1], it.[Inventory]">
                    </asp:EntityDataSource>
                </ContentTemplate>
            </asp:RoleGroup>
            <asp:RoleGroup Roles="SalesTeam">
                <ContentTemplate>
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        DataSourceID="EntityDataSource1" BackColor="White" BorderColor="#999999" 
                        BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
                        <AlternatingRowStyle BackColor="#DCDCDC" />
                        <Columns>
                            <asp:BoundField DataField="pID" HeaderText="ProductID" ReadOnly="True" 
                                SortExpression="pID" />
                            <asp:BoundField DataField="Product1" HeaderText="Product" ReadOnly="True" 
                                SortExpression="Product1" />
                            <asp:BoundField DataField="Inventory" HeaderText="Inventory" ReadOnly="True" 
                                SortExpression="Inventory" />
                        </Columns>
                        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                        <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                        <SortedAscendingCellStyle BackColor="#F1F1F1" />
                        <SortedAscendingHeaderStyle BackColor="#0000A9" />
                        <SortedDescendingCellStyle BackColor="#CAC9C9" />
                        <SortedDescendingHeaderStyle BackColor="#000065" />
                    </asp:GridView>
                    <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
                        ConnectionString="name=VortexEntities" DefaultContainerName="VortexEntities" 
                        EnableFlattening="False" EntitySetName="Products" 
                        Select="it.[pID], it.[Product1], it.[Inventory]">
                    </asp:EntityDataSource>
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
    </asp:LoginView>
    </asp:Content>
